package com.icoolkj.mall.user.openfeign.demo.config;

import com.icoolkj.mall.user.openfeign.demo.interceptor.FeignAuthRequestInterceptor;
import feign.Contract;
import feign.Feign;
import feign.Logger;
import feign.codec.Decoder;
import feign.codec.Encoder;
import feign.jackson.JacksonDecoder;
import feign.jackson.JacksonEncoder;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author icoolkj
 * @version 1.0
 * @description
 * @createDate 2025/01/21 19:37
 */
// 注意： 此处配置@Configuration注解就会全局生效，如果想指定对应微服务生效，就不能配置@Configuration
@Configuration
public class FeignConfig {

    /**
     * 日志级别
     * @return
     */
    @Bean
    public Logger.Level feignLoggerLevel(){
        return Logger.Level.FULL;
    }

//    @Bean
//    public Contract feignContract(){
//        return new Contract.Default();
//    }

    @Bean
    public Encoder encoder(){
        return new JacksonEncoder();
    }

    @Bean
    public Decoder decoder(){
        return new JacksonDecoder();
    }

    /**
     * 自定义拦截器
     * @return
     */
//    @Bean
//    public FeignAuthRequestInterceptor feignAuthRequestInterceptor(){
//        return new FeignAuthRequestInterceptor();
//    }

}
